package com.example.leakcanarydemo

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.os.Message
import android.util.Log
import kotlinx.android.synthetic.main.activity_a.*

class AActivity : AppCompatActivity() {
    var handler = Handler(Looper.getMainLooper())
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_a)
        button1.setOnClickListener {
            App.addContext(this)
            startActivity(Intent(this, AActivity::class.java))
            finish()
        }
        button3.setOnClickListener {
            handler.sendMessageDelayed(Message.obtain(), 6000 * 1000)
            startActivity(Intent(this, AActivity::class.java))
            finish()
        }
        button4.setOnClickListener {
            longRun()
        }
    }

    fun longRun() {
        Thread.sleep(5000)
    }
}